// ignore_for_file: file_names, must_be_immutable, constant_identifier_names, slash_for_doc_comments, avoid_unnecessary_containers, prefer_const_constructors, unnecessary_cast, sized_box_for_whitespace, prefer_function_declarations_over_variables, overridden_fields, annotate_overrides

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

/**跳转页面 */
class FFGoto{
    /**
   * 跳转到某个页面
   */
  static Future gotoPage(BuildContext context, Widget pageWidget,
      {bool fullscreenDialog = false}) {
    return Navigator.push(
        context,
        MaterialPageRoute(
            builder: (context) => pageWidget,
            fullscreenDialog: fullscreenDialog));
  }

  /**
   * 跳转并替换当前页面
   */
  static Future replacePage(BuildContext context, Widget pageWidget,
      {bool fullscreenDialog = false}) {
    return Navigator.pushReplacement(
        context,
        MaterialPageRoute(
            builder: (context) => pageWidget,
            fullscreenDialog: fullscreenDialog));
  }

  /**
   * 返回页面
   */
  static pop(BuildContext context,{bool? isRoot = false}) {
      if (isRoot == true) {
        Navigator.of(context).popUntil((route) => route.isFirst);
      } else {
        if (Navigator.canPop(context)) Navigator.pop(context);
      }
  }
}